package com.cn.serverline.lineicp.workshopPlan.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.serverline.lineicp.workshopPlan.entity.PlanLineSchedule;
import com.cn.serverline.lineicp.workshopPlan.mapper.PlanLineScheduleMapper;
import com.cn.serverline.lineicp.workshopPlan.service.IPlanLineScheduleService;
import com.cn.serverline.lineicp.workshopPlan.util.DateUtil;
import org.springframework.stereotype.Service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;

import javax.xml.crypto.Data;
import java.util.Date;


/**
 * <p>
 * 周部装排产下发 服务实现类
 * </p>
 *
 * @author 田江余
 * @since 2024-08-10
 */
@Service("PlanLineScheduleServiceImpl")
public class PlanLineScheduleServiceImpl extends ServiceImpl<PlanLineScheduleMapper, PlanLineSchedule> implements IPlanLineScheduleService {

    /**
     * 排产下发
     * @param planLineSchedule 请求参数
     */
    @Override
    public void add(PlanLineSchedule planLineSchedule) {
        //创建时间
        planLineSchedule.setCreateTime(DateUtil.getTimestamp());
        this.save(planLineSchedule);
    }

    /**
     *
     * 撤回下发
     * @param planLineSchedule 请求参数
     */
    @Override
    public void del(PlanLineSchedule planLineSchedule) {
        this.removeById(planLineSchedule);
    }

    @Override
    public void edit(PlanLineSchedule planLineSchedule) {
        //修改时间
        planLineSchedule.setUpdateTime(DateUtil.getTimestamp());
        this.updateById(planLineSchedule);
    }

    @Override
    public PlanLineSchedule detail(PlanLineSchedule planLineSchedule) {
        return this.getById(planLineSchedule);
    }

    @Override
    public PageResult<PlanLineSchedule> findPage(PlanLineSchedule planLineSchedule) {
        LambdaQueryWrapper<PlanLineSchedule> wrapper = new LambdaQueryWrapper<>();
        // 筛选主要属性
        /* wrapper.select(PlanLineSchedule::getId, PlanLineSchedule::getPositionName, PlanLineSchedule::getCode, PlanLineSchedule::getRemark,
        PlanLineSchedule::getPositionSort, BaseEntity::getCreateTime);*/

        Page<PlanLineSchedule> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
        return PageResultFactory.createPageResult(sysRolePage);
    }
}
